package com.wanghengzhi.kata;

/**
 *
 * @author wanghengzhi
 * @since 2021/11/10 22:54
 */
public class BackstagePassTwo extends Goods {
    public BackstagePassTwo(int quality, int sellIn) {
        super("Backstage Pass Two", quality, sellIn);
    }

    @Override
    void updateByDay() {
        sellIn = sellIn - 1;
        if (sellIn > 10) {
            quality = quality + 1;
            setQualityFiftyIfGreatThanMaxValue();
        } else if (sellIn > 5) {
            quality = quality + 2;
            setQualityFiftyIfGreatThanMaxValue();
        } else if (sellIn > 0) {
            quality = quality + 3;
            setQualityFiftyIfGreatThanMaxValue();
        } else {
            quality = 0;
        }
    }

    private void updateByDay2() {
        increaseByOneIfQualityLessThanGoodsMaxValue();
        decreaseSellInByOne();
        if (sellIn < 10) {
            increaseByOneIfQualityLessThanGoodsMaxValue();
        }
        if (sellIn < 5) {
            increaseByOneIfQualityLessThanGoodsMaxValue();
        }
        if (isExpired()) {
            quality = 0;
        }
    }


}
